package com.gec.web.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//@WebFilter({"/melist","/add","/edit","/del"})
public class LoginFilter implements Filter {

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
			HttpServletRequest req = (HttpServletRequest) request;
			HttpServletResponse resp = (HttpServletResponse) response;
			
			if(req.getSession().getAttribute("member")==null) {//判断session 里面有没有登录信息
				resp.sendRedirect("/gll/melist");//如果没有登录就跳转到登录页面,强制他登录
			}else {
				chain.doFilter(request, response);//已经登录就直接放他过去
			}
		
	}
	

}
